package com.wanmait.hr.service.Impl;

import com.wanmait.hr.mapper.UserMapper;
import com.wanmait.hr.service.ContractService;
import com.wanmait.hr.service.RecordService;
import com.wanmait.hr.service.UserService;
import com.wanmait.hr.util.Pager;
import com.wanmait.hr.util.TimestampEditor;
import com.wanmait.hr.vo.Contract;
import com.wanmait.hr.vo.User;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.InitBinder;

import javax.annotation.Resource;
import java.sql.Timestamp;
import java.util.List;

@Service("UserService")
public class UserServiceImpl implements UserService
{
    @Resource
    private UserMapper userMapper;

    @Resource
    private  RecordService recordService;
    @Resource
    private ContractService contractService;

    @Override //--王志斌_获得所有的部门经理
    public List<User> findAllSys() {
        return userMapper.findAllSys();
    }
    @Override
    @Transactional
    public void addStaff(User user, String time, Contract c) {//添加员工--陈正儒
        userMapper.addStaff(user);
        recordService.addRecord(user,time);
        contractService.addContract(time,c);


    }

    @Override
    public User findByOneUser(String emailName) { //--张思浩_通过邮箱名查找用户
        return userMapper.findByOneUser(emailName);
    }

    @Override
    public void modifyPassword(User user) {
        userMapper.modifyPassword(user);
    }

    @Override
    public List<User> getStaffInfo(User user) {/*获得不同条件的人员信息*/
        return userMapper.getStaffInfo(user);
    }

    @Override
    public void batchDeleteUser(String[] id) {/*花名册批量删除--陈正儒*/
        userMapper.batchDeleteUser(id);
    }

    @Override
    public void deleteUser(int id) {/*花名册单独删除--陈正儒*/
        userMapper.deleteUser(id);
    }

    @Override
    public List<User> getPersonnelChanges(User user) {//获得异动人员--陈正儒
        return userMapper.getPersonnelChanges(user);
    }

    /**显示个人信息时获取登陆用户id_王志斌
     * @param user
     * @return User
     * */
    @Override
    public User getUserInfoById(User user) {
        return userMapper.getUserInfoById(user);
    }


}
